package com.gui;

import java.awt.ComponentOrientation;
import java.awt.Font;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.WindowConstants;

import com.QuranParser;

import com.dataModel.Quran;

public class MainFrame extends JFrame implements KeyListener{
	
	JTextArea jta=new JTextArea();
	String ayah;
	int counter=0;
	public MainFrame()
	{
		this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
		super.setTitle("My Quran");
		super.setSize(500, 600);
		super.getContentPane().add(new JScrollPane(jta));
		for(Font f:GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts())
		{
			//System.out.println(f.getFamily());
		} 
		int l=GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts().length;
		System.out.println("font length="+l);
		Font font=new Font("Arial Bold",1,30);
		jta.setFont(font);
		load();
		jta.addKeyListener(this);
		super.setVisible(true);
		
	}
	void load()
	{
		
		jta.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
        jta.setText(getSourah(17));
	
	
	}
	String getSourah(int number)
	{
		String surah="";
		Quran quran=QuranParser.getQuran();
		
		for(int i=0;i<quran.getSowar()[number].getAyat().size();i++)
		{
			surah+=quran.getSowar()[number].getAyat().get(i).getTextMoshakal()+"["+(i+1)+"]";
		}
		
		return surah;
		
	}
	public void keyPressed(KeyEvent arg0) {

//		Font font=GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()[counter];
//		
//		System.out.println(counter+" "+font.getName());
//				counter++;
//				
//				jta.setFont(new Font(font.getName(),1,50));
//			
//				// jta.setText(getSourah(113));
//				jta.updateUI();
		
	}
	public void keyReleased(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	public void keyTyped(KeyEvent arg0) {
		// TODO Auto-generated method stub
		
	}

}
